﻿
@page "/Wms/OtherOutWarehouseDetail/Edit"
@using nERP.ViewModel.Wms.OtherOutWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
  <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit" >
    <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
      <BootstrapInput @bind-Value="@Model.Entity.Seq"/>
      <Select @bind-Value="@Model.Entity.OtherOutWarehouseId" Items="AllOtherOutWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g96586dd41bbf44fa8c9a96d735c03b53"/>
      <BootstrapInput @bind-Value="@Model.Entity.OtherOutWarehouseDetailCode"/>
      <Select @bind-Value="@Model.Entity.WarehouseId" Items="AllWarehouses" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="ga7480c2fd1604663944fa579855601b8"/>
      <Select @bind-Value="@Model.Entity.GoodsId" Items="AllGoodss" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="ge0f1747151584419ab417b97d214de7b"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsName"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsSpec"/>
      <BootstrapInput @bind-Value="@Model.Entity.GoodsUnit"/>
            <BootstrapInput @bind-Value="@Model.Entity.OtherOutNumber" FormatString="0.##" />
      <BootstrapInput @bind-Value="@Model.Entity.Remark"/>
    </Row>

    <div class="modal-footer table-modal-footer">
      <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
      <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
    </div>

  </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private OtherOutWarehouseDetailVM Model = new OtherOutWarehouseDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {
                        
        
        await PostsForm(vform, "/api/Wms/OtherOutWarehouseDetail/Edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
    }
    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllOtherOutWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllOtherOutWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherOutWarehouseDetail/GetOtherOutWarehouses");
        AllOtherOutWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherOutWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherOutWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        if (id != "")
        {
            var rv = await WtmBlazor.Api.CallAPI<OtherOutWarehouseDetailVM>($"/api/Wms/OtherOutWarehouseDetail/{id}");
            Model = rv.Data;
        }

        await base.OnInitializedAsync();
    }
}
